home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 9.3 KB | 260 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: AlgnObFr.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef ALGNOBFR_H
- #include "AlgnObFr.h"
- #endif
-
- // ----- Framewrk Layer -----
-
- #ifndef FWPUSHBU_H
- #include "FWPushBu.h"
- #endif
-
- #ifndef FWRADIOB_H
- #include "FWRadioB.h"
- #endif
-
- #ifndef FWCLUSTR_H
- #include "FWClustr.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- //========================================================================================
- // Runtime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment opfdraw
- #endif
-
- //========================================================================================
- // CLASS CAlignObjectsFrame
- //========================================================================================
-
- const ODID CAlignObjectsFrame::kOkButtonId = 0;
- const ODID CAlignObjectsFrame::kCancelButtonId = 1;
- const ODID CAlignObjectsFrame::kTopToBottomClusterId = 2;
- const ODID CAlignObjectsFrame::kLeftToRightClusterId = 3;
- const ODID CAlignObjectsFrame::kNoneId = 4;
- const ODID CAlignObjectsFrame::kTopEdgesId = 5;
- const ODID CAlignObjectsFrame::kCenterId = 6;
- const ODID CAlignObjectsFrame::kBottomEdgesId = 7;
- const ODID CAlignObjectsFrame::kDistributeSpaceId = 8;
- const ODID CAlignObjectsFrame::kSampleAlignmentId = 9;
-
- //----------------------------------------------------------------------------------------
- // CAlignObjectsFrame::CAlignObjectsFrame
- //----------------------------------------------------------------------------------------
-
- CAlignObjectsFrame::CAlignObjectsFrame(ODFrame* odFrame, CDrawPart* drawPart) :
- FW_CFrame(odFrame, drawPart),
- fConnection(this)
- {
- fConnection.Connect();
- }
-
- //----------------------------------------------------------------------------------------
- // CAlignObjectsFrame::~CAlignObjectsFrame
- //----------------------------------------------------------------------------------------
-
- CAlignObjectsFrame::~CAlignObjectsFrame()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CAlignObjectsFrame::CreateViewLayout
- //----------------------------------------------------------------------------------------
-
- void CAlignObjectsFrame::CreateViewLayout(Environment* ev)
- {
- // ----- Create the Top to Bottom radio cluster
-
- FW_CRadioCluster* tbCluster =
- FW_NEW(FW_CRadioCluster, (FW_TYPEID_FROM_TYPE(FW_CRadioCluster),
- this, kTopToBottomClusterId, FW_CPoint(ff(10), ff(10)), FW_CPoint(ff(160), ff(120)),
- "Top to Bottom", kNoneId));
-
- FW_CRadioButton* noAlign =
- FW_NEW(FW_CRadioButton, (FW_TYPEID_FROM_TYPE(FW_CRadioButton),
- tbCluster, kNoneId, FW_CPoint(ff(10), ff(10)), FW_CPoint(ff(155), ff(18)),
- "None"));
-
- FW_CRadioButton* topAlign =
- FW_NEW(FW_CRadioButton, (FW_TYPEID_FROM_TYPE(FW_CRadioButton),
- tbCluster, kTopEdgesId, FW_CPoint(ff(10), ff(30)), FW_CPoint(ff(155), ff(18)),
- "Align top edges"));
-
- FW_CRadioButton* centerAlign =
- FW_NEW(FW_CRadioButton, (FW_TYPEID_FROM_TYPE(FW_CRadioButton),
- tbCluster, kCenterId, FW_CPoint(ff(10), ff(50)), FW_CPoint(ff(155), ff(18)),
- "Align centers"));
-
- FW_CRadioButton* bottomAlign =
- FW_NEW(FW_CRadioButton, (FW_TYPEID_FROM_TYPE(FW_CRadioButton),
- tbCluster, kBottomEdgesId, FW_CPoint(ff(10), ff(70)), FW_CPoint(ff(155), ff(18)),
- "Align bottom edges"));
-
- FW_CRadioButton* distributeAlign =
- FW_NEW(FW_CRadioButton, (FW_TYPEID_FROM_TYPE(FW_CRadioButton),
- tbCluster, kDistributeSpaceId, FW_CPoint(ff(10), ff(90)), FW_CPoint(ff(155), ff(18)),
- "Distribute space"));
-
- // ----- Create the Left to Right radio cluster
-
- FW_CRadioCluster* lrCluster =
- FW_NEW(FW_CRadioCluster, (FW_TYPEID_FROM_TYPE(FW_CRadioCluster),
- this, kTopToBottomClusterId, FW_CPoint(ff(190), ff(10)), FW_CPoint(ff(160), ff(120)),
- "Top to Bottom", kNoneId));
-
- noAlign =
- FW_NEW(FW_CRadioButton, (FW_TYPEID_FROM_TYPE(FW_CRadioButton),
- lrCluster, kNoneId, FW_CPoint(ff(10), ff(10)), FW_CPoint(ff(155), ff(18)),
- "None"));
-
- topAlign =
- FW_NEW(FW_CRadioButton, (FW_TYPEID_FROM_TYPE(FW_CRadioButton),
- lrCluster, kTopEdgesId, FW_CPoint(ff(10), ff(30)), FW_CPoint(ff(155), ff(18)),
- "Align top edges"));
-
- centerAlign =
- FW_NEW(FW_CRadioButton, (FW_TYPEID_FROM_TYPE(FW_CRadioButton),
- lrCluster, kCenterId, FW_CPoint(ff(10), ff(50)), FW_CPoint(ff(155), ff(18)),
- "Align centers"));
-
- bottomAlign =
- FW_NEW(FW_CRadioButton, (FW_TYPEID_FROM_TYPE(FW_CRadioButton),
- lrCluster, kBottomEdgesId, FW_CPoint(ff(10), ff(70)), FW_CPoint(ff(155), ff(18)),
- "Align bottom edges"));
-
- distributeAlign =
- FW_NEW(FW_CRadioButton, (FW_TYPEID_FROM_TYPE(FW_CRadioButton),
- lrCluster, kDistributeSpaceId, FW_CPoint(ff(10), ff(90)), FW_CPoint(ff(155), ff(18)),
- "Distribute space"));
-
- // ----- Create the sample alignment
-
- CSampleAlignmentView* sampleAlignment =
- FW_NEW(CSampleAlignmentView, (FW_TYPEID_FROM_TYPE(CSampleAlignmentView),
- this, kSampleAlignmentId, FW_CPoint(ff(10), ff(125)), FW_CPoint(ff(155), ff(75))));
-
- // ----- Create the Cancel button
-
- FW_CPushButton* cancelButton =
- FW_NEW(FW_CPushButton, (FW_TYPEID_FROM_TYPE(FW_CPushButton),
- this, kCancelButtonId, FW_CPoint(ff(200), ff(180)), FW_CPoint(ff(60), ff(20)),
- "Cancel"));
- FW_CInterest cancelInterest(cancelButton, cancelButton->GetButtonPressedNotificationToken());
- fConnection.AddInterest(cancelInterest, &CAlignObjectsFrame::HandleButtonPressed);
-
- // ----- Create the OK button
-
- FW_CPushButton* okButton =
- FW_NEW(FW_CPushButton, (FW_TYPEID_FROM_TYPE(FW_CPushButton),
- this, kOkButtonId, FW_CPoint(ff(280), ff(180)), FW_CPoint(ff(60), ff(20)),
- "OK"));
- okButton->SetDefault(TRUE);
- FW_CInterest okInterest(okButton, okButton->GetButtonPressedNotificationToken());
- fConnection.AddInterest(okInterest, &CAlignObjectsFrame::HandleButtonPressed);
- }
-
- //----------------------------------------------------------------------------------------
- // CAlignObjectsFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CAlignObjectsFrame::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_CFacetContext fc(ev, odFacet, invalidShape);
-
- FW_CRectShape::RenderRect(fc, GetBounds(ev), FW_kFill, FW_kWhiteEraseInk);
- }
-
- //----------------------------------------------------------------------------------------
- // CAlignObjectsFrame::HandleButtonPressed
- //----------------------------------------------------------------------------------------
-
- void CAlignObjectsFrame::HandleButtonPressed(const FW_CNotification& notification)
- {
- const FW_CButtonPressedNotification& buttonPressedNotification =
- (FW_CButtonPressedNotification&) notification;
-
- if (buttonPressedNotification.GetButtonId() == kOkButtonId)
- {
- // Get the data out of the controls and do the alignment
- }
-
- GetPart()->CloseDialogWindowDeferred(GetWindow());
- }
-
- //========================================================================================
- // CLASS CSampleAlignmentView
- //========================================================================================
-
- FW_DEFINE_CLASS_M1(CSampleAlignmentView, FW_CView)
-
- //----------------------------------------------------------------------------------------
- // CSampleAlignmentView::CSampleAlignmentView
- //----------------------------------------------------------------------------------------
-
- CSampleAlignmentView::CSampleAlignmentView(const FW_CClassInfo& classInfo,
- FW_CFrame* frame, ODID id,
- const FW_CPoint& location,
- const FW_CPoint& size) :
- FW_CView(classInfo, frame, id, location, size)
- {
- CheckForInitialize(classInfo);
- }
-
- //----------------------------------------------------------------------------------------
- // CSampleAlignmentView::CSampleAlignmentView
- //----------------------------------------------------------------------------------------
-
- CSampleAlignmentView::CSampleAlignmentView(const FW_CClassInfo& classInfo,
- FW_CView* enclosure, ODID id,
- const FW_CPoint& location,
- const FW_CPoint& size) :
- FW_CView(classInfo, enclosure, id, location, size)
- {
- CheckForInitialize(classInfo);
- }
-
- //----------------------------------------------------------------------------------------
- // CSampleAlignmentView::~CSampleAlignmentView
- //----------------------------------------------------------------------------------------
-
- CSampleAlignmentView::~CSampleAlignmentView()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CSampleAlignmentView::Draw
- //----------------------------------------------------------------------------------------
-
- void CSampleAlignmentView::Draw(const FW_CViewContext& gc)
- {
- FW_CPoint size = GetSize();
-
- FW_CRect rect(ff(0), ff(0), ff(50), ff(15));
- FW_CRectShape::RenderRect((FW_CViewContext *) &gc, rect, FW_kFrame);
-
- rect.Set(size.x - ff(12), size.y - ff(30), size.x, size.y);
- FW_CRectShape::RenderRect((FW_CViewContext *) &gc, rect, FW_kFrame);
- }
-